import React, { Component } from 'react'
import { connect } from 'dva';
import { Link } from 'dva/router';
import Avatar from '../components/Avatar'
import Footer from '../components/Footer';
import {  List } from 'antd-mobile';
import constans from '../constan';
import styles from './MyPage.css';
import cons from '../constan'
const Item = List.Item;
//const alert = Modal.alert;
class MyPage extends Component {
  constructor(props) {
    super(props)
    this.state = {
      value: ''
    }
  }
  // eslint-disable-next-line
  componentWillMount() {
    this.props.dispatch({
      type:'pagedata/changepage',
      payload: cons.MyPage
    })
  }
  render() {
    console.log(this.props.pagedata);
    let { nowpage } = this.props.pagedata;
    let { login_state } = this.props.user;
    let link_to = login_state !== constans.SuccessLogin ? '/login' : '/my/info';
    return (
      <div>
        <Link to={link_to}>
          <Avatar user={this.props.user} />
        </Link>
        <div className={styles.listwrap}>
          <List renderHeader={() => '常用功能'}>
            <Item
              thumb="https://zos.alipayobjects.com/rmsportal/dNuvNrtqUztHCwM.png"
              arrow="horizontal"
              onClick={() => { }}
            >我的订单
                </Item>
            <Item
              thumb="https://zos.alipayobjects.com/rmsportal/UmbJMbWOejVOpxe.png"
              onClick={() => { }}
              arrow="horizontal"
            >
              {
                <Link to='/cart' className={styles.links}>
                  购物车
                  </Link>
              }
            </Item>
            <Item
              thumb="https://zos.alipayobjects.com/rmsportal/UmbJMbWOejVOpxe.png"
              onClick={() => { }}
              arrow="horizontal"
            >
              我的收藏
                </Item>
            <Item
              thumb="https://zos.alipayobjects.com/rmsportal/UmbJMbWOejVOpxe.png"
              onClick={() => { }}
              arrow="horizontal"
            >
              {
                <Link to='/recent' className={styles.links}>
                  最近学习
                  </Link>
              }
            </Item>
          </List>
        </div>
        <Footer
          wselect={nowpage}
        />
      </div>
    );
  }
}

MyPage.propTypes = {
};
function mapStateToProps({ pagedata, user }) {
  return {
    pagedata,
    user
  }
}
export default connect(mapStateToProps)(MyPage);
